package cn.com.api.mapper.base;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.com.api.entity.ApiT_news;

//DAO
public interface T_newsMapperBase {

	// 根据id查看
	@Select("SELECT * FROM t_news  WHERE rid = #{rid}")
	public ApiT_news findT_newsById(Integer rid);

	// 查看数据集
	@Select("SELECT * FROM T_news")
	public List<ApiT_news> findT_newss();

	// 添加
	@Insert("INSERT INTO t_news (titles, ctype, keyword, contents, appdate, origin, appip, appuser, modtype, enable, accept, ctype_b, city_id, picname, c_order, product_id, price, is_delete, status,goods_id) VALUES (#{titles}, #{ctype}, #{keyword}, #{contents}, #{appdate}, #{origin}, #{appip}, #{appuser}, #{modtype}, #{enable}, #{accept}, #{ctype_b}, #{city_id}, #{picname}, #{c_order}, #{product_id}, #{price}, #{is_delete}, #{status}, #{goods_id})")
	@Options(useGeneratedKeys = true, keyProperty = "rid")
	public int insertT_news(ApiT_news t_news);

	// 修改
	@Update("UPDATE t_news SET titles = #{titles}, ctype = #{ctype}, keyword = #{keyword}, contents = #{contents}, appdate = #{appdate}, origin = #{origin}, appip = #{appip}, appuser = #{appuser}, modtype = #{modtype}, enable = #{enable}, accept = #{accept}, ctype_b = #{ctype_b}, city_id = #{city_id}, picname = #{picname}, c_order = #{c_order}, product_id = #{product_id}, price = #{price}, is_delete = #{is_delete}, status = #{status}, goods_id = #{goods_id} WHERE rid = #{rid}")
	public int updateT_news(ApiT_news t_news);

	// 删除
	@Delete("DELETE FROM t_news  WHERE rid = #{rid}")
	public int deleteT_news(Integer rid);

	// Foreign keys revelant

	// region Indexs revelant

	// 获取根据ctype
	@Select("SELECT rid, titles, ctype, keyword, contents, appdate, origin, appip, appuser, modtype, enable, accept, ctype_b, city_id, picname, c_order, product_id, price, is_delete, status FROM t_news  WHERE ctype = #{ctype}")
	public List<ApiT_news> findT_newssByCtype(String ctype);

	// 获取根据titles
	@Select("SELECT rid, titles, ctype, keyword, contents, appdate, origin, appip, appuser, modtype, enable, accept, ctype_b, city_id, picname, c_order, product_id, price, is_delete, status FROM t_news  WHERE titles = #{titles}")
	public List<ApiT_news> findT_newssByTitles(String titles);

}
